//
//  EGMCategory.h
//  EGMLibrary
//
//  Created by hh on 16/2/29.
//  Copyright © 2016年 egoman. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

#pragma mark - UIButton
@interface UIButton (EGMButton)
-(void)egm_setTitle:(NSString*)title;
-(void)egm_setTitleKey:(NSString*)key;
-(void)egm_setBackgroundImage:(NSString*)imageName;
-(void)egm_setImage:(NSString*)imageName;
-(void)egm_setTitleColor:(UIColor*)color;
-(void)egm_setAttributeTitle:(NSString*)title;
@end

#pragma mark - NSMutableData
@interface NSMutableData(EGMMutableData)
-(void)egm_appendZero:(NSInteger)start end:(NSInteger)end;
@end

#pragma mark - NSData
@interface NSData(EGMData)
-(NSData*)egm_validUTF16Data;
@end

#pragma mark - NSObject
@interface NSObject (EGMReflection)
- (NSArray*)egm_propertyKeys;
- (BOOL)egm_reflectDataFromOtherObject:(id)dataSource;
-(NSDictionary*)egm_convert2Dictionary;
-(void)egm_addIntoDictionary:(NSMutableDictionary*)dict;
- (BOOL)egm_reflectDataFromJsonDictionary:(id)dataSource;
@end


#pragma mark - UITextField
@interface UITextField(EGMTextField)
@property(nonatomic,assign) NSNumber* egm_maxLength;
-(void)egm_setMaxLength:(NSUInteger)maxLength;
@end


#pragma mark - UIView
@interface UIView(EGMUIView)
@property(nonatomic,strong) NSNumber* egm_visibility;

typedef enum {
    EGMConstraintTypeWidth          = 1,
    EGMConstraintTypeHeight         = 1<<1,
    EGMConstraintTypeMarginTop      = 1<<2,
    EGMConstraintTypeMarginBottom   = 1<<3,
    EGMConstraintTypeMarginLeft     = 1<<4,
    EGMConstraintTypeMarginRight    = 1<<5
} EGMConstraintType;

typedef enum {
    EGMVisible          = 1,
    EGMInvisible,
    EGMGone,
    EGMGoneFilledByRight,
    EGMGoneFilledByBottom
} EGMVisibility;

-(void)egm_setVisibility:(EGMVisibility)visibility;
-(void)egm_setWidth:(CGFloat)width;
-(void)egm_setHeight:(CGFloat)height;
-(void)egm_setMargin:(CGFloat)margin constraintType:(EGMConstraintType)type toView:(UIView*)view;
-(void)egm_recoveryConstraint:(EGMConstraintType)constraintType;
-(void)egm_recoveryAllConstraint;
-(void)egm_setOnClickAction:(SEL)action withTarget:(id)target;
-(void)egm_shape2RoundedRect:(float)cornerRadius borderWidth:(float)borderWidth;
-(void)egm_shape2RoundedRect;
-(void)egm_setBackgroundColor:(UIColor*)color;
@end

#pragma mark - UIPickerView
//@interface UIPickerView(EGMPickerView)
//-(void)reloadSucceedingComponent:(NSInteger)component;
//@end


#pragma mark - UIColor
#define RGBA_COLOR(R, G, B, A) [UIColor colorWithRed:((R) / 255.0f) green:((G) / 255.0f) blue:((B) / 255.0f) alpha:A]
#define RGB_COLOR(R, G, B) [UIColor colorWithRed:((R) / 255.0f) green:((G) / 255.0f) blue:((B) / 255.0f) alpha:1.0f]

@interface UIColor (Hex)

+ (UIColor *)colorWithHexString:(NSString *)color;

//从十六进制字符串获取颜色，
//color:支持@“#123456”、 @“0X123456”、 @“123456”三种格式
+ (UIColor *)colorWithHexString:(NSString *)color alpha:(CGFloat)alpha;

@end

#pragma mark - NSString
@interface NSString (Dir)
+(NSString*)egm_cacheDir;
+(NSString*)egm_libDir;
+(NSString*)egm_shareDir;
+(NSString*)egm_fromInt:(NSInteger)value;
@end

#pragma mark - NSURL
@interface NSURL (Dir)
+(NSURL*)egm_cacheDir;
+(NSURL*)egm_libDir;
+(NSURL*)egm_shareDir;
@end


#pragma mark - UIViewController
@interface UIViewController (EGMController)
-(UIViewController*)egm_controllerWithId:(NSString*)identifier;
+(UIViewController*)egm_controllerIn:(NSString*)storyboard withId:(NSString*)identifier;
+ (UIViewController *)egmTopViewController ;
- (void)setStatusBarBackgroundColor:(UIColor *)color ;
-(void)presentVC:(UIViewController *)vc animated:(BOOL)flag completion:(void (^)(void))completion;
@end


#pragma mark - UILabel
@interface UILabel (EGMLabel)
+ (void)egm_setDash:(UILabel *)labels, ... NS_REQUIRES_NIL_TERMINATION ;
@end
